home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / demo / demosrc / d_surfview.pro < prev    next >
Text File  |  1997-07-08  |  60KB  |  1,531 lines

  1. ; $Id: d_surfview.pro,v 1.23 1997/04/23 02:42:04 tremblay Exp $
  2. ;
  3. ;  Copyright (c) 1997, Research Systems, Inc. All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5. ;
  6. ;+
  7. ;  FILE:
  8. ;       d_surfview.pro
  9. ;
  10. ;  CALLING SEQUENCE: d_surfview
  11. ;
  12. ;  PURPOSE:
  13. ;       This application shows the IDL 5.0 functionalities of a surface.
  14. ;
  15. ;  MAJOR TOPICS: Visualization
  16. ;
  17. ;  CATEGORY:
  18. ;       IDL 5.0
  19. ;
  20. ;  INTERNAL FUNCTIONS and PROCEDURES:
  21. ;       fun wsu_ToggleOffOn          - Toggle between 'off' and 'on'
  22. ;       pro wsu_AnimateSurface50     - Animate the surface
  23. ;       pro wsu_AddTracePoint        - Add a tracing point
  24. ;       pro wsu_Surfview50_Event     - Event handler
  25. ;       pro surfview_Cleanup         - Cleanup
  26. ;       pro wsu_Surfview50           - Main procedure
  27. ;
  28. ;  EXTERNAL FUNCTIONS, PROCEDURES, and FILES:
  29. ;       pro trackball__define        - Create the trackball object
  30. ;       fun gettips                  - Read the tip file
  31. ;       pro widtips                  - Create the text widgets for tip
  32. ;       pro sizetips                 - Size the text widgets for tip
  33. ;       pro puttips                  - Cahnge the tip text
  34. ;       surfview.txt
  35. ;
  36. ;  REFERENCE: IDL Reference Guide, IDL User's Guide
  37. ;
  38. ;  NAMED STRUCTURES:
  39. ;       none.
  40. ;
  41. ;  COMMON BLOCS:
  42. ;       none.
  43. ;
  44. ;  MODIFICATION HISTORY:
  45. ;       9/96,   DD   - Written.  
  46. ;       10/96,  DAT  - New GUI.
  47. ;-
  48. ;----------------------------------------------------------------------------
  49. ;
  50. ;  Purpose :  Toggle the string 'off' and 'on' of a widget name. 
  51. ;             Function returns -1 on failure, 0 on 'off', 1 on 'on'.
  52. ;
  53. function wsu_ToggleOffOn, $
  54.     widgetID      ; IN: widget identifier for which its value is the name
  55.  
  56.     WIDGET_CONTROL, widgetID, GET_VALUE=name
  57.  
  58.     ;  Toggle the 'off' and 'on' strings. 
  59.     ;  Otherwise, the function retuns -1.
  60.     ;
  61.     offPosition = STRPOS(name, '(off)')
  62.     if (offPosition ne -1) then begin
  63.         STRPUT, name, '(on )', offPosition
  64.         returnFlag = 1
  65.     endif else begin
  66.         onPosition = STRPOS(name, '(on )')
  67.         if (onPosition ne -1) then begin
  68.             STRPUT, name, '(off)', onPosition
  69.             returnFlag = 0
  70.         endif else begin
  71.             returnFlag = -1
  72.         endelse
  73.     endelse
  74.  
  75.     WIDGET_CONTROL, widgetID, SET_VALUE=name
  76.  
  77.     RETURN, returnFlag
  78.  
  79. end
  80.  
  81. ;----------------------------------------------------------------------------
  82. ;
  83. ;  Purpose:  Animate the surface object.
  84. ;
  85. pro wsu_AnimateSurface, $
  86.     sState, $            ; IN: sState structure
  87.     scenario             ; IN: index indicating the specified animation
  88.  
  89.     ;  Get the x and y dimension of the surface object.
  90.     ;
  91.     xdim = sState.xSizeData
  92.     ydim = sState.ySizeData
  93.  
  94.     case scenario of
  95.  
  96.         ;  This animation deforms the middle of the surface back an forth   
  97.         ;  by translating the x and y coordinates.
  98.         ;
  99.         0 : begin
  100.             x = FLTARR(xdim, ydim)
  101.             for i = 0, 10 do begin
  102.                 floatIndex = FLOAT(i)
  103.                 for j = 0, xdim-1 do x(j, *) = j
  104.                 for j = 0, ydim-1 do x(*, j) = x(*,j) $
  105.                     + floatIndex*SIN(j*(!PI/20.0))
  106.                 sState.oSurface->SetProperty, DATAX = x
  107.                 sState.oWindow->Draw, sState.oView
  108.             endfor
  109.             for i = 9, 0, -1 do begin
  110.                 floatIndex = FLOAT(i)
  111.                 for j = 0, xdim-1 do x(j, *) = j
  112.                 for j = 0, ydim-1 do x(*, j) = x(*,j) $
  113.                     + floatIndex*SIN(j*(!pi/20.0))
  114.                 sState.oSurface->SetProperty, DATAX=x
  115.                 sState.oWindow->Draw, sState.oView
  116.             endfor
  117.         end           ; of 1
  118.  
  119.     endcase
  120.  
  121. end   ; of Animate
  122.  
  123. ;----------------------------------------------------------------------------
  124. ;
  125. ;  Purpose:  Add a data point to the trace path.
  126. ;
  127. pro wsu_AddTracePoint, $
  128.     oTrace, $        ;  IN: polyline object of the trace
  129.     xyzVector, $     ;  IN: x, y, z, vector of the new data point
  130.     status           ;  OUT:  -1: failure, 1: success
  131.  
  132.     ;  Verify the validity of oTrace.
  133.     ;
  134.     if (OBJ_VALID(oTrace) eq 0 ) then begin
  135.         PRINT,'Error in wsu_AddTracePoint: invalid trace polyline object.'
  136.         status = -1
  137.         RETURN
  138.     endif
  139.  
  140.     ;  Verify that xyzVector contains 3 elements.
  141.     ;
  142.     sizexyz = SIZE(xyzVector)
  143.     if ((sizexyz(1) ne 3)) then begin  
  144.         PRINT,'Error in wsu_AddTracePoint:' 
  145.         PRINT,'The dimension of xyzVector must be 3.'
  146.         status = -1
  147.         RETURN
  148.     endif
  149.  
  150.     ;  Get the size of data and the current number of points.
  151.     ;
  152.     oTrace->GetProperty, DATA=data, POLYLINE=connectivityList
  153.     sizeData = size(data)
  154.     nCurrentPoints = connectivityList(0)
  155.     
  156.     ;  Return if the number of points exceeds the data size.
  157.     ;
  158.     if (nCurrentPoints GT sizeData(2)-2) then begin
  159.         PRINT,'Error in wsu_AddTracePoint:' 
  160.         PRINT,'The number of data points exceeds the dimension of data'
  161.         status = -1
  162.         RETURN
  163.     endif
  164.  
  165.     ;  Add the data point.
  166.     ;
  167.     data(0,nCurrentPoints) = xyzVector(0)
  168.     data(1,nCurrentPoints) = xyzVector(1)
  169.     data(2,nCurrentPoints) = xyzVector(2)
  170.     connectivityList(nCurrentPoints+1) = nCurrentPoints
  171.     connectivityList(nCurrentPoints+2) = -1
  172.     connectivityList(0) = nCurrentPoints + 1
  173.     oTrace->SetProperty, DATA=data, POLYLINE=connectivityList
  174.  
  175.     status = 1
  176.          
  177. end        ;  of wsu_AddDataPoint
  178.  
  179. ;----------------------------------------------------------------------------
  180. ;
  181. ;  Purpose:  Handle the event.
  182. ;
  183. pro surfview50_event, $
  184.     sEvent         ; IN: event structure
  185.  
  186.     ;  Quit the application using the close box.
  187.     ;
  188.     if (TAG_NAMES(sEvent, /STRUCTURE_NAME) EQ $
  189.         'WIDGET_KILL_REQUEST') then begin
  190.         WIDGET_CONTROL, sEvent.top, /DESTROY
  191.         RETURN
  192.     endif
  193.  
  194.     WIDGET_CONTROL, sEvent.id, GET_UVAL=uval
  195.  
  196.     case uval of
  197.  
  198.         ;  Animate the surface accordingly to scenario number 0.
  199.         ;
  200.         'ANIMATE' : begin
  201.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  202.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  203.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  204.             wsu_AnimateSurface, sState, 0
  205.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  206.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  207.         end        ; of ANIMATE
  208.  
  209.         ;  Change the font.
  210.         ;
  211.         'FONT' : begin
  212.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  213.             case sEvent.index of
  214.                 0: sState.oFont->SetProperty, NAME='Helvetica'
  215.                 1: sState.oFont->SetProperty, NAME='Times'
  216.                 2: begin
  217.                      if (!VERSION.OS_FAMILY eq "Windows") then $
  218.                          sState.oFont->SetProperty, NAME='Courier New' $
  219.                      else sState.oFont->SetProperty, NAME='Courier'
  220.                 end    ; of case 2
  221.             endcase
  222.             sState.oWindow->Draw, sState.oView
  223.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  224.         end        ; of FONT
  225.  
  226.         ;  Set the shading to flat.
  227.         ;
  228.         'FLAT' : begin
  229.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  230.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  231.             sState.oSurface->SetProperty, SHADING=0
  232.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  233.             sState.oWindow->Draw, sState.oView
  234.             WIDGET_CONTROL, sState.wFlatButton, SENSITIVE=0
  235.             WIDGET_CONTROL, sState.wGouraudButton, SENSITIVE=1
  236.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  237.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  238.         end        ;  of FLAT
  239.  
  240.         ;  Set the shading to gouraud.
  241.         ;
  242.         'GOURAUD' : begin
  243.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  244.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  245.             sState.oSurface->SetProperty, SHADING=1
  246.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  247.             sState.oWindow->Draw, sState.oView
  248.             WIDGET_CONTROL, sState.wFlatButton, SENSITIVE=1
  249.             WIDGET_CONTROL, sState.wGouraudButton, SENSITIVE=0
  250.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  251.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  252.         end        ;  of GOURAUD
  253.  
  254.         ;  Set the style to point.
  255.         ;
  256.         'POINT' : begin
  257.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  258.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  259.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
  260.             sState.oSurface->SetProperty, STYLE=0
  261.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  262.             sState.oWindow->Draw, sState.oView    
  263.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=0
  264.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
  265.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
  266.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
  267.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
  268.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
  269.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
  270.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
  271.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=0
  272.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  273.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  274.         end        ;  of POINT
  275.  
  276.         ;  Set the style to wire.
  277.         ;
  278.         'WIRE' : begin
  279.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  280.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  281.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
  282.             sState.oSurface->SetProperty, STYLE=1
  283.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  284.             sState.oWindow->Draw, sState.oView    
  285.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
  286.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=0
  287.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
  288.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
  289.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
  290.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
  291.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
  292.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
  293.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
  294.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  295.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  296.         end        ;  of POINT
  297.  
  298.         ;  Set the style to solid.
  299.         ;
  300.         'SOLID' : begin
  301.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  302.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  303.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=1
  304.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  305.             sState.oSurface->SetProperty, STYLE=2
  306.             sState.oWindow->Draw, sState.oView    
  307.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
  308.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
  309.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=0
  310.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
  311.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
  312.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
  313.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
  314.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=0
  315.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=0
  316.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  317.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  318.         end        ;  of SOLID
  319.  
  320.         ;  Set the style to ruled xz.
  321.         ;
  322.         'RULEDXZ' : begin
  323.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  324.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  325.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
  326.             sState.oSurface->SetProperty, STYLE=3
  327.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  328.             sState.oWindow->Draw, sState.oView    
  329.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
  330.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
  331.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
  332.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=0
  333.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
  334.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
  335.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
  336.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
  337.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
  338.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  339.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  340.         end        ;  of RULEDXZ
  341.  
  342.         ;  Set the style to ruled yz.
  343.         ;
  344.         'RULEDYZ' : begin
  345.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  346.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  347.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
  348.             sState.oSurface->SetProperty, STYLE=4
  349.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  350.             sState.oWindow->Draw, sState.oView    
  351.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
  352.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
  353.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
  354.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
  355.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=0
  356.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
  357.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
  358.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
  359.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
  360.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  361.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  362.         end        ;  of RULEDYZ
  363.  
  364.         ;  Set the style to lego wire.
  365.         ;
  366.         'LEGOWIRE' : begin
  367.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  368.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  369.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
  370.             sState.oSurface->SetProperty, STYLE=5
  371.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  372.             sState.oWindow->Draw, sState.oView    
  373.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
  374.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
  375.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
  376.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
  377.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
  378.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=0
  379.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=1
  380.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
  381.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
  382.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  383.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  384.         end        ;  of LEGOWIRE
  385.  
  386.         ;  Set the style to lego solid.
  387.         ;
  388.         'LEGOSOLID' : begin
  389.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  390.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  391.             WIDGET_CONTROL, sState.wTracingButton, SENSITIVE=0
  392.             sState.oSurface->SetProperty, STYLE=6
  393.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  394.             sState.oWindow->Draw, sState.oView    
  395.             WIDGET_CONTROL, sState.wPointButton, SENSITIVE=1
  396.             WIDGET_CONTROL, sState.wWireButton, SENSITIVE=1
  397.             WIDGET_CONTROL, sState.wSolidButton, SENSITIVE=1
  398.             WIDGET_CONTROL, sState.wRuledXZButton, SENSITIVE=1
  399.             WIDGET_CONTROL, sState.wRuledYZButton, SENSITIVE=1
  400.             WIDGET_CONTROL, sState.wLegoWireButton, SENSITIVE=1
  401.             WIDGET_CONTROL, sState.wLegoSolidButton, SENSITIVE=0
  402.             WIDGET_CONTROL, sState.wHiddenButton, SENSITIVE=1
  403.             WIDGET_CONTROL, sState.wLineStyleButton, SENSITIVE=1
  404.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  405.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  406.         end        ;  of LEGOSOLID
  407.  
  408.         ;  Set minimum value. 
  409.         ;
  410.         'SHOWMIN': begin
  411.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  412.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  413.             WIDGET_CONTROL, sState.wMinSlider, GET_VALUE=min
  414.             WIDGET_CONTROL, sState.wMaxSlider, GET_VALUE=max
  415.  
  416.             min = FLOAT(min) / 100.0
  417.             max = FLOAT(max) / 100.0
  418.             minString = 'Minimum: ' + STRING(min, FORMAT='(f5.2)')
  419.             WIDGET_CONTROL, sState.wMinLabel, $
  420.                 SET_VALUE=minString
  421.  
  422.             sState.oSurface->SetProperty, MIN_VALUE=min
  423.             sState.oSurface->SetProperty, MAX_VALUE=max
  424.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  425.             sState.oWindow->Draw, sState.oView    
  426.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  427.         end        ;  of SHOWMIN
  428.  
  429.         ;  Set maximum value. 
  430.         ;
  431.         'SHOWMAX': begin
  432.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  433.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  434.             WIDGET_CONTROL, sState.wMinSlider, GET_VALUE=min
  435.             WIDGET_CONTROL, sState.wMaxSlider, GET_VALUE=max
  436.             min = FLOAT(min) / 100.0
  437.             max = FLOAT(max) / 100.0
  438.             maxString = 'Maximum: ' + STRING(max, FORMAT='(f5.2)')
  439.             WIDGET_CONTROL, sState.wMaxLabel, $
  440.                 SET_VALUE=maxString
  441.  
  442.             sState.oSurface->SetProperty, MIN_VALUE=min
  443.             sState.oSurface->SetProperty, MAX_VALUE=max
  444.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  445.             sState.oWindow->Draw, sState.oView    
  446.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  447.         end        ;  of SHOWMAX
  448.  
  449.         ;  Set scaling
  450.         ;
  451.         'SCALING': begin
  452.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  453.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  454.             WIDGET_CONTROL, sState.wScalingSlider, GET_VALUE=scale
  455.  
  456.             scale = 0.75 + FLOAT(scale) / 100.0
  457.             scalep = scale*100.0
  458.             scalingString = 'Scaling : ' + STRING(scalep, $
  459.                 FORMAT='(f5.1)') + ' %'
  460.             WIDGET_CONTROL, sState.wScalingLabel, $
  461.                 SET_VALUE=scalingString
  462.  
  463.             transform = [[scale, 0, 0, 0.0], [0, scale, 0, 0.0], $
  464.                 [0, 0, scale, 0.0], [0, 0, 0, 1]]
  465.             sState.oMovableScalingModel->SetProperty, TRANSFORM=transform
  466.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  467.             sState.oWindow->Draw, sState.oView    
  468.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  469.         end        ;  of SCALING
  470.  
  471.         ;  Reset the initial orientation of the surface
  472.         ;
  473.         'RESETTRANSFORM': begin
  474.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  475.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  476.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  477.             sState.oMovableRotationModel->SetProperty, $
  478.                 TRANSFORM=sState.initTransformRotation
  479.             sState.oWindow->Draw, sState.oView    
  480.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  481.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  482.         end        ;  of RESETTRANSFORM
  483.  
  484.         ;  Toggle off and on the texture mapping.
  485.         ;
  486.         'TEXTURE' : begin
  487.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  488.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  489.             WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
  490.             j = wsu_ToggleOffOn(sEvent.id)
  491.             case j of
  492.  
  493.                  0: begin
  494.                      sState.oSurface->SetProperty, TEXTURE_MAP=OBJ_NEW()
  495.                      WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=1
  496.                  end    ;   of  0
  497.  
  498.                  1: begin
  499.                      sState.oSurface->SetProperty, $
  500.                          TEXTURE_MAP=sState.oTextureImage
  501.                      WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
  502.                  end    ;   of  1
  503.  
  504.                 -1: PRINT, 'Error in wsu_ToggleOffOn/texture.'
  505.  
  506.             endcase
  507.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  508.             sState.oWindow->Draw, sState.oView    
  509.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  510.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  511.         end        ;  of TEXTURE
  512.  
  513.         ;  Toggle off and on the vertex colors.
  514.         ;
  515.         'VERTEXCOLOR' : begin
  516.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  517.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  518.             j = wsu_ToggleOffOn(sEvent.id)
  519.             case j of
  520.                  0: sState.oSurface->SetProperty, VERT_COLORS=0
  521.                  1: sState.oSurface->SetProperty, $
  522.                     VERT_COLORS=sState.vertexColors
  523.                 -1: PRINT, 'Error in wsu_ToggleOffOn/vertexcolors.'
  524.             endcase
  525.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  526.             sState.oWindow->Draw, sState.oView    
  527.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  528.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  529.         end        ;  of VERTEXCOLOR
  530.  
  531.         ;  Toggle off and on the hidden points and lines.
  532.         ;
  533.         'HIDE' : begin
  534.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  535.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  536.             j = wsu_ToggleOffOn(sEvent.id)
  537.             if (j eq -1) then begin
  538.                  PRINT, 'Error in wsu_ToggleOffOn/hide.'
  539.                  RETURN
  540.             endif
  541.             sState.oSurface->SetProperty, HIDDEN_LINES=j
  542.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  543.             sState.oWindow->Draw, sState.oView    
  544.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  545.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  546.         end        ;  of HIDE
  547.  
  548.         ;  Toggle between solid and dash linestyles.
  549.         ;
  550.         'LINESTYLE' : begin
  551.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  552.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  553.             j = wsu_ToggleOffOn(sEvent.id)
  554.             case j of
  555.                  0: sState.oSurface->SetProperty, LINESTYLE=0 ; solid
  556.                  1: sState.oSurface->SetProperty, LINESTYLE=[1,'5555'X] ; dash
  557.                 -1: PRINT, 'Error in wsu_ToggleOffOn/linestyle.'
  558.             endcase
  559.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  560.             sState.oWindow->Draw, sState.oView    
  561.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  562.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  563.         end        ;  of LINESTYLE
  564.  
  565.         ;  Show no skirt.
  566.         ;
  567.         'SKIRTNONE' : begin
  568.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  569.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  570.             sState.oSurface->SetProperty, SHOW_SKIRT = 0
  571.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  572.             sState.oWindow->Draw, sState.oView    
  573.             WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=0
  574.             WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=1
  575.             WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=1
  576.             WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=1
  577.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  578.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  579.         end        ;  of SKIRTNONE
  580.  
  581.         ;  Set skirt to -0.5.
  582.         ;
  583.         'SKIRT10' : begin
  584.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  585.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  586.             sState.oSurface->SetProperty, SKIRT=-0.5, /SHOW_SKIRT
  587.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  588.             sState.oWindow->Draw, sState.oView    
  589.             WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=1
  590.             WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=0
  591.             WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=1
  592.             WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=1
  593.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  594.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  595.         end        ;  of SKIR10
  596.  
  597.         ;  Set skirt to 0.0.
  598.         ;
  599.         'SKIRT20' : begin
  600.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  601.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  602.             sState.oSurface->SetProperty, SKIRT=0.0, /SHOW_SKIRT
  603.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  604.             sState.oWindow->Draw, sState.oView    
  605.             WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=1
  606.             WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=1
  607.             WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=0
  608.             WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=1
  609.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  610.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  611.         end        ;  of SKIR20
  612.  
  613.         ;  Set skirt to 0.5.
  614.         ;
  615.         'SKIRT30' : begin
  616.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  617.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=0
  618.             sState.oSurface->SetProperty, SKIRT=0.5, /SHOW_SKIRT
  619.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  620.             sState.oWindow->Draw, sState.oView    
  621.             WIDGET_CONTROL, sState.wSkirtNoneButton, SENSITIVE=1
  622.             WIDGET_CONTROL, sState.wSkirt10Button, SENSITIVE=1
  623.             WIDGET_CONTROL, sState.wSkirt20Button, SENSITIVE=1
  624.             WIDGET_CONTROL, sState.wSkirt30Button, SENSITIVE=0
  625.             WIDGET_CONTROL, sState.wTopBase, SENSITIVE=1
  626.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  627.         end        ;  of SKIR30
  628.  
  629.         ;  Set drag quality to low.
  630.         ;
  631.         'LOW' : begin
  632.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  633.             sState.dragq = 0
  634.             WIDGET_CONTROL, sState.wLowButton, SENSITIVE=0
  635.             WIDGET_CONTROL, sState.wMediumButton, SENSITIVE=1
  636.             WIDGET_CONTROL, sState.wHighButton, SENSITIVE=1
  637.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  638.         end        ;  of LOW
  639.  
  640.         ;  Set drag quality to medium.
  641.         ;
  642.         'MEDIUM' : begin
  643.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  644.             sState.dragq = 1
  645.             WIDGET_CONTROL, sState.wLowButton, SENSITIVE=1
  646.             WIDGET_CONTROL, sState.wMediumButton, SENSITIVE=0
  647.             WIDGET_CONTROL, sState.wHighButton, SENSITIVE=1
  648.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  649.         end        ;  of MEDIUM
  650.  
  651.         ;  Set drag quality to high.
  652.         ;
  653.         'HIGH' : begin
  654.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  655.             sState.dragq = 2
  656.             WIDGET_CONTROL, sState.wLowButton, SENSITIVE=1
  657.             WIDGET_CONTROL, sState.wMediumButton, SENSITIVE=1
  658.             WIDGET_CONTROL, sState.wHighButton, SENSITIVE=0
  659.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  660.         end        ;  of HIGH
  661.  
  662.         ;  Draw only the surface within the tracing 
  663.         ;  contour (trace mask on),
  664.         ;  or draw the whole surface (trace mask on).
  665.         ;  Toggle between these 2 options.
  666.         ;
  667.         'TRACING_MASK' : begin
  668.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  669.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  670.  
  671.             if (sState.tracingMode EQ 1) then begin
  672.  
  673.                 j = wsu_ToggleOffOn(sEvent.id)
  674.                 case j of
  675.                     0: sState.oSurface->SetProperty, TEXTURE_MAP=OBJ_NEW()
  676.                     1: begin
  677.                         sState.oTracePolyline->GetProperty, $
  678.                             DATA=data, POLYLINE=connectivityList
  679.                         sState.oTracingMask->GetProperty, DATA=idata
  680.                         mask = BYTARR(400, 400)
  681.                         if (connectivityList(0) ge 3) then begin
  682.                             ;  Get the number of current points minus 1
  683.                             ;
  684.                             nCurrentPointsM1 = connectivityList(0) - 1
  685.                             x = data(0, 0:nCurrentPointsM1) * 10.0
  686.                             y = data(1, 0:nCurrentPointsM1) * 10.0
  687.                             fill = POLYFILLV(x, y, 400, 400)            
  688.                             mask(*, *) = 0
  689.                             mask(fill) = 255
  690.                         endif else begin
  691.                             mask(*, *) = 255
  692.                         endelse
  693.                         idata(*, *, 3) = mask
  694.                         sState.oTracingMask->SetProperty, DATA=idata
  695.                         sState.oSurface->SetProperty, $
  696.                             TEXTURE_MAP=sState.oTracingMask
  697.                     end          ; of 1
  698.                    -1: PRINT, 'Error in wsu_ToggleOffOn/tracingMask.'
  699.                 endcase
  700.  
  701.                 WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
  702.                 WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=0
  703.                 WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=1
  704.                 textChange = ['reset', 'erase']
  705.                 putTips, sState.sText, sState.wText[1], $
  706.                     textChange, [1,2]
  707.  
  708.  
  709.             ;  Reset the tracing features to its initial status. The
  710.             ;  tracing manipulation can be repeated.
  711.             ;
  712.             endif else begin
  713.  
  714.                 sState.oSurface->SetProperty, TEXTURE_MAP=OBJ_NEW()
  715.                 j = wsu_ToggleOffOn(sState.wTracingModeButton)
  716.                 j = wsu_ToggleOffOn(sState.wTracingMaskButton)
  717.                 j = wsu_ToggleOffOn(sState.wTracingResetButton)
  718.                 WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=1
  719.                 WIDGET_CONTROL, sState.wStyleButton, SENSITIVE=1
  720.                 WIDGET_CONTROL, sState.wTextureButton, SENSITIVE=1
  721.                 WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=0
  722.                 WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
  723.                 textChange = ['infor', 'instr']
  724.                 putTips, sState.sText, sState.wText[1], $
  725.                     textChange, [1,2]
  726.                 sState.tracingMode = 0
  727.             endelse
  728.  
  729.             sState.oWindow->Draw, sState.oView    
  730.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  731.         end         ; of TRACING_MASK
  732.  
  733.         ;  Enable (on) or disable (off) the tracing mode.
  734.         ;  Toggle between these 2 options.
  735.         ;  
  736.         'TRACING_MODE' : begin
  737.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  738.             j = wsu_ToggleOffOn(sEvent.id)
  739.             if (j eq -1) then begin
  740.                  PRINT, 'Error in wsu_ToggleOffOn/tracingMode.'
  741.                  RETURN
  742.             endif
  743.             sState.tracingMode = 1
  744.             WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
  745.             WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=0
  746.             WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
  747.             WIDGET_CONTROL, sState.wTextureButton, SENSITIVE=0
  748.             WIDGET_CONTROL, sState.wStyleButton, SENSITIVE=0
  749.             textChange = ['regio', 'right']
  750.             putTips, sState.sText, sState.wText[1], $
  751.                 textChange, [1,2]
  752.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  753.         end         ; of TRACING_MODE
  754.  
  755.         ;  Tracing reset erases the tracing lines (res lines).
  756.         ;  
  757.         'TRACING_RESET' : begin
  758.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  759.             WIDGET_CONTROL, sEvent.top, /HOURGLASS
  760.             j = wsu_ToggleOffOn(sEvent.id)
  761.             sState.oTracePolyline->GetProperty, POLYLINE=connectivityList
  762.             connectivityList(0) = 0
  763.             connectivityList(1) = -1
  764.             sState.oTracePolyline->SetProperty, $
  765.                 POLYLINE=connectivityList
  766.             sState.oWindow->Draw, sState.oView    
  767.             sState.tracingMode = 0
  768.             textChange = ['mask1', 'whole']
  769.             putTips, sState.sText, sState.wText[1], $
  770.                 textChange, [1,2]
  771.             WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
  772.             WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=1
  773.             WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
  774.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  775.         end         ; of TRACING_RESET
  776.  
  777.         ;  Handle the event that occurs in the drawing (viewing) area.
  778.         ;  These are : expose and mouse button(press, motion, release).
  779.         ;  
  780.         'DRAW': begin
  781.             WIDGET_CONTROL, sEvent.top, GET_UVALUE=sState, /NO_COPY
  782.  
  783.             ;  Expose.
  784.             ;
  785.             if (sEvent.type eq 4) then begin
  786.                 sState.oWindow->draw, sState.oView
  787.                 WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  788.                 RETURN
  789.             endif
  790.  
  791.             ;  Handle trackball update
  792.             ;
  793.             bHaveTransform = sState.oTrack->Update(sEvent, TRANSFORM=qmat )
  794.             if (bHaveTransform NE 0) then begin
  795.                 sState.oMovableRotationModel->GetProperty, TRANSFORM=t
  796.                 mt = t # qmat
  797.                 sState.oMovableRotationModel->SetProperty,TRANSFORM=mt
  798.             endif
  799.  
  800.             ;  Button press.
  801.             ;
  802.             if (sEvent.type EQ 0) then begin
  803.  
  804.                 ;  Right button press.
  805.                 ;
  806.                 if (sEvent.press EQ 4) then begin
  807.                     pick = sState.oWindow->PickData(sState.oView, $
  808.                     sState.oSurface, [sEvent.x, sEvent.y], dataxyz)
  809.                     if (pick ne 0) then begin
  810.                          statusString = STRING(dataxyz(0), $
  811.                              dataxyz(1),dataxyz(2), $
  812.                              FORMAT='("X=", F6.2,' + $
  813.                              ' ", Y=",F6.2,", Z=",F6.2)')
  814.                         sState.sText.text[7] = statusString
  815.                         textChange = ['locat', 'void']
  816.                         putTips, sState.sText, sState.wText[1], $
  817.                             textChange, [1,2]
  818.                         if (sState.tracingMode eq 1) then begin
  819.                             wsu_AddTracePoint, sState.oTracePolyline, $
  820.                                 dataxyz, check
  821.                             sState.firstPoint = dataxyz
  822.                             if (check eq -1) then begin
  823.                                 PRINT,'Error in wsu_AddTracePoint/Draw.'
  824.                             endif
  825.                             sState.oWindow->Draw, sState.oView
  826.                         endif
  827.                         sState.btndown = 4b
  828.                         WIDGET_CONTROL, sState.wDraw, /DRAW_MOTION
  829.                     endif else begin
  830.                         sState.sText.text[7] ="Data point:In background"
  831.                         textChange = ['void']
  832.                         putTips, sState.sText, sState.wText[1], $
  833.                             textChange, [2]
  834.                     endelse
  835.                 endif else begin
  836.                     sState.btndown = 1b
  837.                     sState.oWindow->SetProperty, QUALITY=sState.dragq
  838.                     WIDGET_CONTROL, sState.wDraw, /DRAW_MOTION
  839.                 endelse
  840.             endif    ; ev.typ EQ 0
  841.  
  842.             ;  Button motion and tracing mode
  843.             ;
  844.             if ((sEvent.type eq 2) and (sState.btndown eq 4b)) then begin
  845.                 pick = sState.oWindow->PickData(sState.oView, $
  846.                 sState.oSurface, [sEvent.x, sEvent.y], dataxyz)
  847.                 if (pick ne 0) then begin
  848.                      statusString = STRING(dataxyz(0), $
  849.                          dataxyz(1),dataxyz(2), $
  850.                          FORMAT='("X=", F6.2,' + $
  851.                          ' ", Y=",F6.2,", Z=",F6.2)')
  852.                         sState.sText.text[7] = statusString
  853.                         textChange = ['locat', 'void']
  854.                         putTips, sState.sText, sState.wText[1], $
  855.                             textChange, [1,2]
  856.                     if (sState.tracingMode ne 0) then begin
  857.                         wsu_AddTracePoint, sState.oTracePolyline, $
  858.                             dataxyz, check
  859.                         if (check eq -1) then begin
  860.                             PRINT,'Error in wsu_AddTracePoint/Draw.'
  861.                         endif
  862.                         sState.oWindow->Draw, sState.oView
  863.                     endif
  864.                 endif else begin
  865.                     sState.sText.text[7] ="Data point:In background"
  866.                     textChange = ['void']
  867.                     putTips, sState.sText, sState.wText[1], $
  868.                         textChange, [2]
  869.                 endelse
  870.             endif
  871.  
  872.             ;  Button motion.
  873.             ;
  874.             if ((sEvent.type eq 2) and (sState.btndown eq 1b)) then begin
  875.                      if (bHaveTransform) then $
  876.                          sState.oWindow->Draw, sState.oView
  877.             endif
  878.  
  879.             ;  Button release.
  880.             ;
  881.             if (sEvent.type eq 1) then begin
  882.                 if (sState.btndown EQ 1b) then begin
  883.                           sState.oWindow->SetProperty, QUALITY=2
  884.                         sState.oWindow->Draw, sState.oView
  885.                 endif else if ((sState.btndown EQ 4b) $
  886.                     AND (sState.tracingmode EQ 1) ) then begin
  887.                     wsu_AddTracePoint, sState.oTracePolyline, $
  888.                         sState.firstPoint, check
  889.                     if (check eq -1) then begin
  890.                         PRINT,'Error in wsu_AddTracePoint/Draw.'
  891.                     endif
  892.                     sState.oWindow->Draw, sState.oView
  893.                     sState.tracingMode = 1
  894.                     textChange = ['mask1', 'displ']
  895.                     putTips, sState.sText, sState.wText[1], $
  896.                         textChange, [1,2]
  897.                     WIDGET_CONTROL, sState.wTracingModeButton, SENSITIVE=0
  898.                     WIDGET_CONTROL, sState.wTracingMaskButton, SENSITIVE=1
  899.                     WIDGET_CONTROL, sState.wTracingResetButton, SENSITIVE=0
  900.                 endif
  901.                 sState.btndown = 0b
  902.                 WIDGET_CONTROL, sState.wDraw, DRAW_MOTION = 0
  903.             endif
  904.             WIDGET_CONTROL, sEvent.top, SET_UVALUE=sState, /NO_COPY
  905.         end   ; of DRAW
  906.  
  907.         ;  Quit the application.
  908.         ;
  909.         'QUIT' : begin
  910.            WIDGET_CONTROL, sEvent.top, /DESTROY
  911.         end   ; of QUIT
  912.  
  913.         ;  Show the information text.
  914.         ;
  915.         'ABOUT' : begin
  916.             ; Verify that there is only one instance of XDisplayfile
  917.             ;
  918.             if (XREGISTERED('XDisplayFile') ne 0) then return
  919.             XDisplayFile, filepath("surfview.txt", $
  920.                SUBDIR=['examples','demo','demotext']), $
  921.                DONE_BUTTON='Done', $
  922.                TITLE="Surface", $
  923.                GROUP=sEvent.top, WIDTH=55, HEIGHT=14
  924.         end   ; of ABOUT
  925.  
  926.     endcase   ; of case uval of
  927.  
  928. end     ; of event handler
  929.  
  930. ;----------------------------------------------------------------------------
  931. ;
  932. ;  Purpose:  Restore the previous color table and
  933. ;            destroy the top objects.
  934. ;  
  935. pro surfview_Cleanup, $
  936.     wTopBase          ;  IN: top level base ID.
  937.     WIDGET_CONTROL, wTopBase, GET_UVALUE=sState, /NO_COPY
  938.  
  939.     ;  Destroy the top objects
  940.     ;
  941.     OBJ_DESTROY, sState.oView
  942.     OBJ_DESTROY, sState.oTextureImage
  943.     OBJ_DESTROY, sState.oTracingMask
  944.     OBJ_DESTROY, sState.oTracK
  945.     OBJ_DESTROY, sState.oText
  946.     OBJ_DESTROY, sState.oFont
  947.     OBJ_DESTROY, sState.oContainer
  948.  
  949.     ;  Restore the color table
  950.     ;
  951.     TVLCT, sState.colorTable
  952.  
  953.     ;  Map the group leader base if it exists.
  954.     ;
  955.     if (WIDGET_INFO(sState.groupBase, /VALID_ID)) then $
  956.         WIDGET_CONTROL, sState.groupBase, /MAP
  957.  
  958. end   ;  of surfview_Cleanup
  959.  
  960.  
  961.  
  962. ;----------------------------------------------------------------------------
  963. ;
  964. ;  Purpose:  Display a surface. Show the IDL 5.0 functionalities.
  965. ;  
  966. pro d_surfview, $
  967.     ALT_FUNC=ALT_FUNC, $       ; IN: (opt) Alternative function : sine dist
  968.     TRANSPARENT=transparent, $ ; IN: (opt) Transparent across a plane  
  969.     GROUP=group, $             ; IN: (opt) group identifier
  970.     APPTLB = appTLB            ; OUT: (opt) TLB of this application
  971.  
  972.     ; Check the validity of the group identifier
  973.     ;
  974.     ngroup = N_ELEMENTS(group)
  975.     if (ngroup NE 0) then begin
  976.         check = WIDGET_INFO(group, /VALID_ID)
  977.         if (check NE 1) then begin
  978.             print,'Error, the group identifier is not valid'
  979.             print, 'Return to the main application'
  980.             RETURN
  981.         endif
  982.         groupBase = group
  983.     endif else groupBase = 0L
  984.  
  985.  
  986.     ;  Set up dimensions of the drawing (viewing) area.
  987.     ;
  988.     device, GET_SCREEN_SIZE=scr
  989.     xdim = scr(0)*0.6
  990.     ydim = xdim*0.8
  991.  
  992.     ;  Get the tips.
  993.     ;
  994.     sText = getTips(filepath('surfview.tip', $
  995.         SUBDIR=['examples','demo', 'demotext']) )
  996.  
  997.     ;  Get the current color vectors to restore
  998.     ;  when this application is exited.
  999.     TVLCT, savedR, savedG, savedB, /GET
  1000.  
  1001.     ; Build color table from color vectors
  1002.     ;
  1003.     colorTable = [[savedR],[savedG],[savedB]]
  1004.  
  1005.     ;  Create widgets.
  1006.     ;
  1007.     if (N_ELEMENTS(group) EQ 0) then begin
  1008.         wTopBase = WIDGET_BASE(/COLUMN, XPAD=0, YPAD=0, $
  1009.             /TLB_KILL_REQUEST_EVENTS, $
  1010.             TLB_FRAME_ATTR=1, MBAR=barBase, $
  1011.             TITLE="Surface Objects")
  1012.     endif else begin
  1013.         wTopBase = WIDGET_BASE(/COLUMN, XPAD=0, YPAD=0, $
  1014.             /TLB_KILL_REQUEST_EVENTS, $
  1015.             TLB_FRAME_ATTR=1, MBAR=barBase, $
  1016.             GROUP_LEADER=group, $
  1017.             TITLE="Surface Objects")
  1018.     endelse
  1019.  
  1020.         ;  Create the menu bar. It contains the file,
  1021.         ;  edit, and help buttons.
  1022.         ;
  1023.         wFileButton = WIDGET_BUTTON(barBase, VALUE = 'File', /MENU)
  1024.             wQuitButton = WIDGET_BUTTON(wFileButton, VALUE='Quit', $
  1025.                 UVALUE='QUIT')
  1026.  
  1027.         ;  Create the menu bar item Edit 
  1028.         ;  that has the shade and style options.
  1029.         ;
  1030.         wOptionButton = WIDGET_BUTTON(barBase, VALUE = 'Options', /MENU)
  1031.  
  1032.             ;  Select the plot shading.
  1033.             ;
  1034.             wShadingButton = WIDGET_BUTTON(wOptionButton, $
  1035.                 VALUE='Shading', UVALUE='SHADING', MENU=1)
  1036.  
  1037.                 wFlatButton = WIDGET_BUTTON(wShadingButton, $
  1038.                    VALUE='Flat', UVALUE='FLAT')
  1039.  
  1040.                 wGouraudButton = WIDGET_BUTTON(wShadingButton, $
  1041.                    VALUE='Gouraud', UVALUE='GOURAUD')
  1042.  
  1043.             ;  Select the plot style.
  1044.             ;
  1045.             wStyleButton = WIDGET_BUTTON(wOptionButton, $
  1046.                 VALUE='Style', UVALUE='STYLE', /MENU)
  1047.  
  1048.                 wPointButton = WIDGET_BUTTON(wStyleButton, $
  1049.                     VALUE='Point', UVALUE='POINT')
  1050.  
  1051.                 wWireButton = WIDGET_BUTTON(wStyleButton, $
  1052.                     VALUE='Wire', UVALUE='WIRE')
  1053.  
  1054.                 wSolidButton = WIDGET_BUTTON(wStyleButton, $
  1055.                     VALUE='Solid', UVALUE='SOLID')
  1056.  
  1057.                 wRuledXZButton = WIDGET_BUTTON(wStyleButton, $
  1058.                     VALUE='Ruled XZ', UVALUE='RULEDXZ')
  1059.  
  1060.                 wRuledYZButton = WIDGET_BUTTON(wStyleButton, $
  1061.                     VALUE='Ruled YZ', UVALUE='RULEDYZ')
  1062.  
  1063.                 wLegoWireButton = WIDGET_BUTTON(wStyleButton, $
  1064.                     VALUE='Lego Wire', UVALUE='LEGOWIRE')
  1065.  
  1066.                 wLegoSolidButton = WIDGET_BUTTON(wStyleButton, $
  1067.                     VALUE='Lego Solid', UVALUE='LEGOSOLID')
  1068.  
  1069.             ;  Select the skirt value.
  1070.             ;
  1071.             wSkirtButton = WIDGET_BUTTON(wOptionButton, $
  1072.                 VALUE='Skirt', UVALUE='SKIRT', /MENU)
  1073.  
  1074.                 ; Remove the skirt
  1075.                 ;
  1076.                 wSkirtNoneButton = WIDGET_BUTTON(wSkirtButton, $
  1077.                     VALUE='None', UVALUE='SKIRTNONE')
  1078.  
  1079.                 ; Skirt10 is  -0.5.
  1080.                 ;
  1081.                 wSkirt10Button = WIDGET_BUTTON(wSkirtButton, $
  1082.                     VALUE='z=-0.5', UVALUE='SKIRT10')
  1083.  
  1084.                 ; Skirt20 is  0.0
  1085.                 ;
  1086.                 wSkirt20Button = WIDGET_BUTTON(wSkirtButton, $
  1087.                     VALUE='z=0.0', UVALUE='SKIRT20')
  1088.  
  1089.                 ; Skirt30 is  0.5
  1090.                 ;
  1091.                 wSkirt30Button = WIDGET_BUTTON(wSkirtButton, $
  1092.                     VALUE='z=0.5', UVALUE='SKIRT30')
  1093.  
  1094.             ;  Set up the drag quality. Low is wire, medium is
  1095.             ;  polygons, high is smoothed polygons.
  1096.             ;
  1097.             wDragButton = Widget_Button(wOptionButton, $
  1098.                 VALUE="Drag Quality", UVALUE='DRAGQ', /MENU)
  1099.  
  1100.                 wLowButton = WIDGET_BUTTON(wDragButton, $
  1101.                     VALUE='Low', UVALUE='LOW')
  1102.  
  1103.                 wMediumButton = WIDGET_BUTTON(wDragButton, $
  1104.                     VALUE='Medium', UVALUE='MEDIUM')
  1105.  
  1106.                 wHighButton = WIDGET_BUTTON(wDragButton, $
  1107.                     VALUE='High', UVALUE='HIGH')
  1108.  
  1109.             ;  Allows to trace a contour on the surface, and
  1110.             ;  then to display only the surface contained within
  1111.             ;  that contour.
  1112.             ;
  1113.             wTracingButton = WIDGET_BUTTON(wOptionButton, $
  1114.                 VALUE='Tracing', UVALUE='TRACING', /MENU)
  1115.  
  1116.                 wTracingModeButton = WIDGET_BUTTON(wTracingButton, $
  1117.                     VALUE='Trace Mode (off)', UVALUE='TRACING_MODE')
  1118.  
  1119.                 wTracingMaskButton = WIDGET_BUTTON(wTracingButton, $
  1120.                     VALUE='Trace Mask (off)', UVALUE='TRACING_MASK')
  1121.  
  1122.                 wTracingResetButton = WIDGET_BUTTON(wTracingButton, $
  1123.                     VALUE='Trace Reset (off)', UVALUE='TRACING_RESET')
  1124.  
  1125.             ;  Toggle between showing or not showing
  1126.             ;  the hidden points and lines.
  1127.             ;
  1128.             wHiddenButton = WIDGET_BUTTON(wOptionButton, $
  1129.                 VALUE="Hidden (off)", UVALUE='HIDE')
  1130.  
  1131.             ;  Toggle between showing or not showing
  1132.             ;  the vertices in colors.
  1133.             ;
  1134.             wVertexButton = WIDGET_BUTTON(wOptionButton, $
  1135.                 VALUE="Vertex Colored (on )", UVALUE='VERTEXCOLOR')
  1136.  
  1137.             ;  Toggle between showing or not showing
  1138.             ;  the texture mapping.
  1139.             ;
  1140.             wTextureButton = WIDGET_BUTTON(wOptionButton, $
  1141.                 VALUE="Texture Mapping (off)", UVALUE='TEXTURE')
  1142.  
  1143.             ;  Toggle between a solid or dash line style.
  1144.             ;
  1145.             wLineStyleButton = WIDGET_BUTTON(wOptionButton, $
  1146.                 VALUE="Line Style (off)", UVALUE='LINESTYLE')
  1147.  
  1148.         ;  Create the menu bar item Edit 
  1149.         ;  that has the shade and style options.
  1150.         ;
  1151.         wViewButton = WIDGET_BUTTON(barBase, VALUE = 'View', /MENU)
  1152.  
  1153.             wAnimateButton = WIDGET_BUTTON(wViewButton, $
  1154.                 VALUE="Animate", UVALUE='ANIMATE')
  1155.  
  1156.             wResetButton = WIDGET_BUTTON(wViewButton, $
  1157.                 VALUE="Reset Orientation", UVALUE='RESETTRANSFORM')
  1158.  
  1159.         ;  Create the menu bar item help that contains the about button.
  1160.         ;
  1161.         wHelpMenu = WIDGET_BUTTON(barBase, VALUE='About', $
  1162.             /HELP, /MENU)
  1163.  
  1164.             wAboutButton = WIDGET_BUTTON(wHelpMenu, $
  1165.                 VALUE='About Surface Objects', UVALUE='ABOUT')
  1166.  
  1167.  
  1168.         ;  Create a sub base of the top base (wBase).
  1169.         ;
  1170.         wSubBase = WIDGET_BASE(wTopBase, COLUMN=2)
  1171.  
  1172.             ;  Create the left Base that contains the functionality buttons.
  1173.             ;  Here the only button is to animate the object.
  1174.             ;
  1175.             wLeftbase = WIDGET_BASE(wSubBase,/BASE_ALIGN_CENTER, $
  1176.                 COLUMN=1)
  1177.  
  1178.                wMinMaxBase = WIDGET_BASE(wLeftBase, $
  1179.                    /COLUMN, YPAD=10)
  1180.  
  1181.                    wMinMaxLabel = WIDGET_LABEL(wMinMaxBase, $
  1182.                        VALUE='Data Range')
  1183.  
  1184.                     minValue = -0.41
  1185.                     minString ='Minimum: ' + STRING(minValue, $
  1186.                         FORMAT='(f5.2)')
  1187.                     wMinLabel = WIDGET_LABEL(wMinMaxBase, $
  1188.                         VALUE=minString)
  1189.  
  1190.                     wMinSlider = WIDGET_SLIDER(wMinMaxBase, $
  1191.                         MINIMUM=-41, $
  1192.                         MAXIMUM=25, VALUE=-41, $
  1193.                         /SUPPRESS_VALUE, $
  1194.                         UVALUE='SHOWMIN')
  1195.  
  1196.                     maxValue = 1.01
  1197.                     maxString ='Maximum: ' + STRING(maxValue, $
  1198.                         FORMAT='(f5.2)')
  1199.                     wMaxLabel = WIDGET_LABEL(wMinMaxBase, $
  1200.                         VALUE=maxString)
  1201.  
  1202.                     wMaxSlider = WIDGET_SLIDER(wMinMaxBase, $
  1203.                         MINIMUM=25, $
  1204.                         MAXIMUM=101, VALUE=101, $
  1205.                         /SUPPRESS_VALUE, $
  1206.                         UVALUE='SHOWMAX')
  1207.  
  1208.                 wScalingBase = WIDGET_BASE(wLeftBase, $
  1209.                     /COLUMN, YPAD=10)
  1210.  
  1211.                     percent = 100
  1212.                     scalingString = 'Scaling : ' + STRING(percent, $
  1213.                         FORMAT='(f5.1)') + ' %'
  1214.                     wScalingLabel = WIDGET_LABEL(wScalingBase, $
  1215.                         VALUE=scalingString)
  1216.  
  1217.                     wScalingSlider = WIDGET_SLIDER(wScalingBase, $
  1218.                         MINIMUM=0, $
  1219.                         MAXIMUM=50, VALUE=25, $
  1220.                         /SUPPRESS_VALUE, $
  1221.                         UVALUE='SCALING')
  1222.  
  1223.             ;  Create the right Base that has the drawing area.
  1224.             ;
  1225.             wRightbase = WIDGET_BASE(wSubBase, COLUMN=1)
  1226.  
  1227.                 wDraw = WIDGET_DRAW(wRightBase, $
  1228.                     GRAPHICS_LEVEL=2, $
  1229.                     XSIZE=xdim, YSIZE=ydim, /BUTTON_EVENTS, $
  1230.                     UVALUE='DRAW', RETAIN=0, /EXPOSE_EVENT)
  1231.  
  1232.         ;  Create tips texts.
  1233.         ;
  1234.         wStatusBase = WIDGET_BASE(wTopBase, MAP=0, /ROW)
  1235.  
  1236.             nWidgets = 2
  1237.             wText = LONARR(nWidgets)
  1238.             widTips, wStatusBase, sText.text, XSIZE=36, $
  1239.                 YSIZE=3, NWIDGETS=nWidgets, wText
  1240.  
  1241.     ;  Now the widget have been created, realize it.
  1242.     ;
  1243.     WIDGET_CONTROL, wTopBase, /REALIZE
  1244.  
  1245.     ; Returns the top level base to the APPTLB keyword.
  1246.     ;
  1247.     appTLB = wtopBase
  1248.  
  1249.     ;  Size the tips widgets.
  1250.     ;
  1251.     sizeTips, wTopBase, wText, wStatusBase
  1252.  
  1253.     ;  Grab the window id of the drawable.
  1254.     ;
  1255.     WIDGET_CONTROL, wDraw, GET_VALUE=oWindow
  1256.  
  1257.     WIDGET_CONTROL, wTopBase, SENSITIVE=0
  1258.  
  1259.  
  1260.     bias = -0.5
  1261.     ;  Compute viewplane rectangle based on aspect ratio.
  1262.     ;
  1263.     aspect = float(xdim)/float(ydim)
  1264.     if (aspect > 1) then $
  1265.         myview = [(1.0-aspect)/2.0+bias, 0.0+bias, aspect, 1.0] $
  1266.     else $
  1267.         myview = [0.0+bias, (1.0-(1.0/aspect))/2.0+bias, 1.0, (1.0/aspect)]
  1268.  
  1269.     ; Create view object.  
  1270.     ;
  1271.     oView = OBJ_NEW('idlgrview', PROJECTION=2, EYE=3, $
  1272.         ZCLIP=[1.5,-1.5], VIEW=myview, COLOR=[0, 0, 0])
  1273.  
  1274.     ;  Make the text location to be centered.
  1275.     ;
  1276.     textLocation = [myview(0)+0.5*myview(2), myview(1)+0.5*myview(3)]
  1277.  
  1278.     ;  Create and display the PLEASE WAIT text.
  1279.     ;
  1280.     oFont = OBJ_NEW('IDLgrFont', 'Helvetica', SIZE=18)
  1281.     oText = OBJ_NEW('IDLgrText', $
  1282.         'Starting up  Please wait...', $
  1283.         ALIGN=0.5, $
  1284.         LOCATION=textLocation, $
  1285.         COLOR=[255,255,0], FONT=oFont)
  1286.  
  1287.     ;  Create model.
  1288.     ;
  1289.     oTopModel = obj_new('idlgrmodel')
  1290.     oMovableModel = OBJ_NEW('idlgrmodel')
  1291.     oMovableScalingModel = OBJ_NEW('idlgrmodel')
  1292.     oMovableRotationModel = OBJ_NEW('idlgrmodel')
  1293.     oTopModel->Add, oMovableModel
  1294.     oMovableModel->Add, oMovableScalingModel
  1295.     oMovableScalingModel->Add, oMovableRotationModel
  1296.  
  1297.     ;  Place the model in the view.
  1298.     ;
  1299.     oView->Add, oTopModel
  1300.  
  1301.     ;  Scale the top model to fit the viewing area.
  1302.     ;
  1303.     sct = 0.6
  1304.     oTopModel->Scale, sct, sct, sct
  1305.  
  1306.     otopModel->Add, oText
  1307.  
  1308.     ;  Draw the starting up screen.
  1309.     ;
  1310.     oWindow->Draw, oView
  1311.  
  1312.     ;  Surface data is a Besel function.
  1313.     ;
  1314.     if (N_ELEMENTS(ALT_FUNC) ne 0) then begin
  1315.         a = DIST(40)
  1316.         a = 8.0*a/MAX(a)
  1317.         z = SIN(a)
  1318.     endif else begin
  1319.        z = BESELJ(SHIFT(DIST(40),20,20)/2,0)
  1320.     endelse
  1321.  
  1322.  
  1323.     ;  Compute coordinate conversion to normalize.
  1324.     ; 
  1325.     sz = SIZE(z)
  1326.     maxx = sz(1) - 1
  1327.     maxy = sz(2) - 1
  1328.     maxz = MAX(z, MIN=minz)
  1329.     xs = [0+bias, 1.0/maxx]
  1330.     ys = [0+bias, 1.0/maxy]
  1331.     minz2 = minz - 1
  1332.     maxz2 = maxz + 1 
  1333.     zs = [-minz2/(maxz2-minz2)+bias, 1.0/(maxz2-minz2)]
  1334.  
  1335.     ;  For height-fields, use the following vertex colors.
  1336.     ;
  1337.     vertexColors = BYTARR(3, 40*40, /NOZERO)
  1338.     cbins= $
  1339.         [[255,   0, 0],$
  1340.          [255,  85, 0],$
  1341.          [255, 170, 0],$
  1342.          [255, 255, 0],$
  1343.          [170, 255, 0],$
  1344.          [85,  255, 0],$
  1345.          [0,   255, 0]]
  1346.  
  1347.     zi = ROUND((z - minz)/(maxz-minz) * 6.0)  
  1348.     vertexColors(*, *) = cbins(*, zi)
  1349.  
  1350.     imagefile = filepath('dave.gif', SUBDIR=['examples','demo','demodata'])
  1351.     void = FINDFILE(imagefile, COUNT=nFile)
  1352.     if (nFile gt 0)then begin
  1353.         READ_GIF, imagefile, $
  1354.         plane, red, green, blue
  1355.         plane = red(plane)
  1356.         sizePlane = SIZE(plane)
  1357.         idata = BYTARR(sizePlane(1), sizePlane(2), 2)
  1358.         if (N_ELEMENTS(transparent) ne 0) then begin
  1359.             idata(*, *, 0) = plane
  1360.             ;  Compute alpha
  1361.             ;
  1362.         t = where( plane eq 255, nPoints)
  1363.         plane(*) = 255
  1364.         if (nPoints ne -1) then begin
  1365.         plane(t) = 0
  1366.         endif
  1367.             idata(*, *, 1) = plane
  1368.             oTextureImage = OBJ_NEW('idlgrImage', idata, $
  1369.                 INTERLEAVE=2)
  1370.         endif else begin
  1371.             oTextureImage = OBJ_NEW('idlgrImage', plane)
  1372.         endelse
  1373.  
  1374.     endif else begin
  1375.         idata = BYTSCL(DIST(100))
  1376.         oTextureImage = OBJ_NEW('idlgrImage', idata)
  1377.     endelse
  1378.  
  1379.     ;  Create the tracing objects.
  1380.     ;
  1381.     workData = BYTARR(400, 400, 4)
  1382.     workData(*, *, *) = 255
  1383.     oTracingMask = OBJ_NEW('idlgrImage', workData, INTERLEAVE=2)
  1384.     tracingData = FLTARR(3, 1024)
  1385.     tracingConnectivityList = LONARR(1024)
  1386.     tracingConnectivityList(0) = 0
  1387.     tracingConnectivityList(1) = -1
  1388.  
  1389.     ;  Create polyline object in the same space as the surface.
  1390.     ;
  1391.     oTracePolyline = OBJ_NEW('idlgrPolyline', $
  1392.         tracingData, POLYLINES=tracingConnectivityList, $
  1393.         COLOR=[255, 0, 0], $
  1394.      XCOORD_CONV=xs, YCOORD_CONV=ys, ZCOORD_CONV=zs, $
  1395.         THICK=3)
  1396.     oMovableRotationModel->Add, oTracePolyline
  1397.  
  1398.     ;  Create surface object.
  1399.     ;
  1400.     oSurface = OBJ_NEW('idlgrSurface', $
  1401.         z, STYLE=2, $
  1402.         SHADING=1, $
  1403.         COLOR=[230, 230, 230], BOTTOM=[64, 192, 128], $
  1404.      XCOORD_CONV=xs, YCOORD_CONV=ys, ZCOORD_CONV=zs)
  1405.  
  1406.     oMovableRotationModel->Add, oSurface
  1407.  
  1408.     ;  Create a light.
  1409.     ;
  1410.     oSunLight = OBJ_NEW('IDLgrLight', LOCATION=[1.5, 0, 1], $
  1411.         TYPE=1, INTENSITY=0.5)
  1412.     otopModel->Add, oSunLight
  1413.     oSunLight = OBJ_NEW('IDLgrLight', TYPE=0, $
  1414.         INTENSITY=0.75)
  1415.     otopModel->Add, oSunLight
  1416.  
  1417.     ; Rotate to standard view for first draw.
  1418.     ;
  1419.     oMovableRotationModel->Rotate, [1, 0, 0], -90
  1420.     oMovableRotationModel->Rotate, [0, 1, 0], 30
  1421.     oMovableRotationModel->Rotate, [1, 0, 0], 30
  1422.  
  1423.     ;  Add the trackball object for interactive change
  1424.     ;  of the scene orientation
  1425.     ;
  1426.     oTrack = OBJ_NEW('Trackball', [xdim/2.0, ydim/2.0], xdim/2.0)
  1427.  
  1428.     oContainer = OBJ_NEW('IDLgrContainer')
  1429.     oContainer->Add, oView
  1430.     oContainer->Add, oTrack
  1431.  
  1432.     oMovableRotationModel->GetProperty, TRANSFORM=initTransformRotation
  1433.     oMovableScalingModel->GetProperty, TRANSFORM=initTransformScaling
  1434.  
  1435.     ;  Create the sState 
  1436.     ;
  1437.     sState = { $
  1438.         ColorTable: colorTable, $
  1439.         Center: xdim/2., $                           ; Center of view
  1440.         Radius: ydim/2, $                            ; Radius 
  1441.         XSizeData: sz(1), $                          ; x data dimension
  1442.         YSizeData: sz(2), $                          ; x data dimension
  1443.         Btndown: 0b, $                               ; Botton down flag
  1444.         Pt0: FLTARR(3), $                            ; Initial point 
  1445.         Pt1: FLTARR(3), $                            ; Final point 
  1446.     Dragq: 0, $                                  ; Drag quality
  1447.         FirstPoint: FLTARR(3), $
  1448.         WDraw: wDraw, $                              ; Widget draw
  1449.         OTrack: oTrack, $
  1450.         OContainer: oContainer, $
  1451.         OTopModel: oTopModel, $                      ; Top model
  1452.         OMovableModel: oMovableModel, $              ; Movable models
  1453.         OMovableScalingModel: oMovableScalingModel, $          
  1454.         OMovableRotationModel: oMovableRotationModel, $       
  1455.         OSurface: oSurface, $                        ; Surface object
  1456.         InitTransformScaling: initTransformScaling, $
  1457.         InitTransformRotation: initTransformRotation, $
  1458.         OView: oView, $                              ; Main view object
  1459.         OFont: oFont, $                              ; Font object
  1460.         OText: oText, $                              ; Text object
  1461.         VertexColors: vertexColors, $                ; Vertex colors(RGB)
  1462.         OTracePolyline: oTracePolyline, $            ; Trace object
  1463.         OTracingMask: oTracingMask, $                ; Tracing mask object
  1464.         OTextureImage: oTextureImage, $              ; Texture image object
  1465.         TracingMode: 0, $                            ; Tracing mode 0=off,1=on
  1466.         OWindow: oWindow, $                          ; Window object
  1467.         WTopBase : wTopBase, $                       ; Top level base
  1468.         WFlatButton : wFlatButton, $                 ; Shading options
  1469.           WGouraudButton : wGouraudButton, $           
  1470.         WStyleButton: wStyleButton, $
  1471.           WPointButton : wPointButton, $             ; Styles options
  1472.           WWireButton : wWireButton, $
  1473.           WSolidButton : wSolidButton, $
  1474.           WRuledXZButton : wRuledXZButton, $
  1475.           WRuledYZButton : wRuledYZButton, $
  1476.           WLegoWireButton : wLegoWireButton, $
  1477.           WLegoSolidButton : wLegoSolidButton, $
  1478.         WSkirtNoneButton : wSkirtNoneButton, $       ; Skirt options
  1479.           WSkirt10Button : wSkirt10Button, $
  1480.           WSkirt20Button : wSkirt20Button, $
  1481.           WSkirt30Button : wSkirt30Button, $
  1482.         WLowButton : wLowButton, $                   ; Drag quality options
  1483.           WMediumButton : wMediumButton, $
  1484.           WHighButton : wHighButton, $
  1485.         WMinSlider: wMinSlider, $                    ; Sliders IDs
  1486.         WMaxSlider: wMaxSlider, $
  1487.         WMinLabel: wMinLabel, $                      ; Sliders label IDs
  1488.         WMaxLabel: wMaxLabel, $                    
  1489.         WScalingSlider: wScalingSlider, $
  1490.         WScalingLabel: wScalingLabel, $
  1491.         WTracingButton : wTracingButton, $           ; Tracing options
  1492.           WTracingModeButton : wTracingModeButton, $  
  1493.           WTracingMaskButton : wTracingMaskButton, $
  1494.           WTracingResetButton : wTracingResetButton, $
  1495.         WHiddenButton : wHiddenButton, $             ; Hidden option
  1496.         WTextureButton : wTextureButton, $           ; Texture mapping option
  1497.         WText: wText, $                              ; Widget text idS for tips
  1498.         SText: sText, $                              ; Text structure for tips
  1499.         WLineStyleButton : wLineStyleButton, $       ; Linestyle option
  1500.         groupBase: groupBase $                       ; Base of Group Leader
  1501.     }  
  1502.  
  1503.     ;  Desensitize the defaults buttons.
  1504.     ;
  1505.     WIDGET_CONTROL, wGouraudButton, SENSITIVE=0
  1506.     WIDGET_CONTROL, wSolidButton, SENSITIVE=0
  1507.     WIDGET_CONTROL, wSkirtNoneButton, SENSITIVE=0
  1508.     WIDGET_CONTROL, wLowButton, SENSITIVE=0
  1509.     WIDGET_CONTROL, wHiddenButton, SENSITIVE=0
  1510.     WIDGET_CONTROL, wLineStyleButton, SENSITIVE=0
  1511.     WIDGET_CONTROL, wTracingMaskButton, SENSITIVE=0
  1512.     WIDGET_CONTROL, wTracingResetButton, SENSITIVE=0
  1513.  
  1514.     WIDGET_CONTROL, wTopBase, SET_UVALUE=sState, /NO_COPY
  1515.  
  1516.     WIDGET_CONTROL, wTopBase, /HOURGLASS
  1517.  
  1518.     ;  Put the color on the surface. 
  1519.     ;
  1520.     oSurface->SetProperty, VERT_COLORS=vertexColors
  1521.     
  1522.     otopModel->Remove, oText
  1523.     oWindow->Draw, oView
  1524.  
  1525.     WIDGET_CONTROL, wTopBase, SENSITIVE=1
  1526.  
  1527.     XMANAGER, 'd_surfview', wTopBase, EVENT_HANDLER='surfview50_event', $
  1528.         CLEANUP='surfview_Cleanup', /NO_BLOCK
  1529.  
  1530. end
  1531.